<template>
  <div class="login-container">
    <div class="login-box">
      <h1 class="login-title">加入我们</h1>
      <el-form
        :model="registerForm"
        label-position="top"
        class="login-form"
      >
        <el-form-item prop="username">
          <el-input
            v-model="registerForm.username"
            placeholder="请输入用户名"
            size="large"
            prefix-icon="User"
            clearable
          >
          </el-input>
        </el-form-item>

        <el-form-item prop="email">
          <el-input
            v-model="registerForm.email"
            type="email"
            size="large"
            placeholder="请输入邮箱"
            clearable
            prefix-icon="message"
          >
          </el-input>
        </el-form-item>

        <el-form-item prop="password">
          <el-input
            v-model="registerForm.password"
            type="password"
            size="large"
            prefix-icon="Lock"
            placeholder="请输入密码"
            clearable
            show-password
          >
          </el-input>
        </el-form-item>

        <el-form-item
          prop="confirmPassword"
        >
          <el-input
            v-model="registerForm.confirmPassword"
            type="password"
            size="large"
            prefix-icon="Lock"
            placeholder="请再次输入密码"
            clearable
            show-password
          >
          </el-input>
        </el-form-item>

        <el-button
          type="warning"
          class="login-btn"
          size="large"
          @click="handleRegister"
        >
          立即注册
        </el-button>
      </el-form>
      <div class="login-footer">
        <p style="display: inline; margin-right: 8px; font-size: 14px">已有账号？</p>
        <el-link
          type="primary"
          :underline="false"
          style="font-size: 14px"
          @click="$router.push('login')"
        >去登录</el-link>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const registerForm = ref({
  username: '',
  email: '',
  password: '',
  confirmPassword: ''
})

const handleRegister = () => {
  console.log('执行注册操作', registerForm.value)
}
</script>

<style scoped>
.login-container {
  height: 100vh;
  background: url('@/assets/login-bg.jpeg') no-repeat center/cover;
  position: relative;
}

.login-box {
  width: 400px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  position: absolute;
  right: 18%;
  top: 50%;
  transform: translateY(-50%);
}

.login-title {
  text-align: center;
  margin-bottom: 30px;
  color: #2d3a4b;
  font-weight: 600;
}

.login-form :deep(.el-form-item__label) {
  font-weight: 500;
  color: #5a5e66;
}

.login-btn {
  width: 100%;
  margin-top: 10px;
}

.login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  color: #888;
  font-size: 14px;
}
</style>